//
//  LCSugarListViewModel.m
//  JKBiblicalReading
//
//  Created by admin on 2018/8/28.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LCSugarListViewModel.h"

@implementation LCSugarListViewModel

- (void)getNewsComposeTextDataWithArray:(NSArray *)array page:(NSInteger)page success:(void (^)(NSDictionary *))successBlock failure:(void (^)(NSError *))failureBlock end:(void (^)(void))endBlock {

    [[LCWebServicesManager sharedInstance] getDonateWithArray:array page:page type:2 success:^(NSDictionary *dict) {
        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
        if(netWorkModel.status == 1){
            
            NSArray<LCSugarListModel *> *array = [NSArray yy_modelArrayWithClass:[LCSugarListModel class] json:netWorkModel.data];
            if (page > 1) {
                [self.dynamicNewsDataMArray addObjectsFromArray:array];
            }else{
                self.dynamicNewsDataMArray = array.mutableCopy;
            }
            if (array.count > 0) {
                if (successBlock) {
                    successBlock(dict);
                }
            }else{
                if (endBlock) {
                    endBlock();
                }
            }
        }else{
            if (failureBlock) {
                failureBlock(nil);
            }
            [SVProgressHUD showErrorWithStatus:netWorkModel.msg];
        }
    } failure:^(NSError *error) {
        if (failureBlock) {
            failureBlock(error);
        }
    } end:^{
        if (endBlock) {
            endBlock();
        }

    }];
}

- (NSMutableArray<LCSugarListModel *> *)dynamicNewsDataMArray{
    if (_dynamicNewsDataMArray == nil) {
        _dynamicNewsDataMArray = [NSMutableArray array];
    }
    return _dynamicNewsDataMArray;
}

@end
